<!DOCTYPE html>
<html>
<head>
    {include file="public/head"}
    <style>
        .btn-disabled{background-color: transparent;}
    </style>
</head>
<body>
<!--<div id="YDUI_NOTIFY"><div class="m-notify">5秒后自动消失，点我也可以消失！</div></div>-->
<div class="g-flexview">
    <header class="m-navbar">
        <a href="javascript:history.back();" class="navbar-item">
            <i class="back-ico"></i>
        </a>
        <div class="navbar-center">
            {if condition="$orderInfo['state']==1&&$orderInfo['is_pay']==0"}
            <span class="navbar-title">待付款</span>
            {elseif condition="$orderInfo['state']==1&&$orderInfo['is_confirm']==0"}
            <span class="navbar-title">待确定</span>
            {/if}
            {if condition="$orderInfo['state']==2"}
            <span class="navbar-title">交易完成</span>
            {/if}
        </div>
    </header>
    <div class="g-scrollview">
        <div class="m-cell">
            <div class="cell-item">
                <div class="cell-left">创建人</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['nickname']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">HX币</div>
                <div class="cell-right">{$orderInfo['money']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">单价</div>
                <div class="cell-right">{$orderInfo['unit_price']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">总金额</div>
                <div class="cell-right">{$orderInfo['unit_price']*$orderInfo['money']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">真实姓名</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['name']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">手机号</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['phone']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">银行卡</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['bank_no']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">开户银行</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['open_bank']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">微信号</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['weixin']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">支付宝</div>
                <div class="cell-right">{:getInfo($orderInfo['user_id'])['alipay']}</div>
            </div>
            <div class="cell-item">
                <div class="cell-left">时间</div>
                <div class="cell-right">{$orderInfo['add_time']|date="Y-m-d H:i:s",###}</div>
            </div>
            <div class="cell-item">
                {if condition="$orderInfo['type'] == 'sell'"}
                <div class="cell-left">买方姓名</div>
                {else/}
                <div class="cell-left">卖方姓名</div>
                {/if}
                <div class="cell-right name">{$buy_user['name']}</div>
            </div>
            <div class="cell-item">
                {if condition="$orderInfo['type'] == 'sell'"}
                <div class="cell-left">买方手机号</div>
                {else/}
                <div class="cell-left">卖方手机号</div>
                {/if}
                <div class="cell-right phone">{$buy_user['phone']}</div>
            </div>
            <div class="cell-item">
                {if condition="$orderInfo['type'] == 'sell'"}
                <div class="cell-left">买方支付宝</div>
                {else/}
                <div class="cell-left">卖方支付宝</div>
                {/if}
                <div class="cell-right alipay">{$buy_user['alipay']}</div>
            </div>
            <div class="cell-item">
                {if condition="$orderInfo['type'] == 'sell'"}
                <div class="cell-left">买方银行卡</div>
                {else/}
                <div class="cell-left">卖方银行卡</div>
                {/if}
                <div class="cell-right bank_no">{$buy_user['bank_no']}</div>
            </div>
            {if condition="$orderInfo['state'] == 1 && $orderInfo['is_expire'] == 0"}
            <div class="cell-item">
                <div class="cell-left">订单剩余有效时间</div>
                <div class="cell-right" id="J_GetCode">

                </div>
            </div>
            {/if}
            <div class="m-button">
                {if condition="$orderInfo['type'] == 'sell' && $orderInfo['is_expire'] == 0"}
                    {if condition="$orderInfo['state']==1&&$orderInfo['is_pay']==0&&$user_id!=$orderInfo['user_id']"}
                    <button type="button" class="btn-block btn-primary pay">已支付</button>
                    {/if}
                    {if condition="$orderInfo['state']==1&&$orderInfo['is_confirm']==0&&$user_id==$orderInfo['user_id']&&$orderInfo['is_pay']==1"}
                    <button type="button" class="btn-block btn-primary confirm">确定</button>
                    {/if}
                {/if}
                {if condition="$orderInfo['type'] == 'buy' && $orderInfo['is_expire'] == 0"}
                    {if condition="$orderInfo['state']==1&&$orderInfo['is_pay']==0&&$user_id==$orderInfo['user_id']"}
                    <button type="button" class="btn-block btn-primary pay" id="buy_pay">已支付</button>
                    {/if}
                    {if condition="$orderInfo['state']==1&&$orderInfo['is_confirm']==0&&$user_id!=$orderInfo['user_id']&&$orderInfo['is_pay']==1"}
                    <button type="button" class="btn-block btn-primary confirm">确定</button>
                    {/if}
                {/if}
            </div>
        </div>
    </div>
</div>
{include file="public/js"}
<script>
    !function ($) {
        // 转账完成后的操作
        $('.pay').click(function () {
            dialog.confirm('提示','确定已经付款成功了?',function () {
                YDUI.dialog.loading.open('处理中...');
                $.post('/index/trade/orderPayConfirm',{id : '{$orderInfo["id"]}',type : 1},function (res) {
                    YDUI.dialog.loading.close();
                    dialog.toast(res.msg,'none',1000,function () {
                        if (res.code == 1){
                            if ("{$orderInfo['type']}" == 'sell') {
                                $.post('/api/sms/orderSuccess',{phone : "{$orderInfo['user_phone']}"});
                                setTimeout(function () {location.reload();},1000);
                            }else {
                                $.post('/api/sms/orderSuccess',{phone : "{$orderInfo['buy_phone']}"});
                                setTimeout(function () {location.reload();},1000);
                            }
                        }
                    });
                });
            });
        });
        // 收到转账金额后的操作
        $('.confirm').click(function () {
            dialog.confirm('提示','确定已经收到款',function () {
                YDUI.dialog.loading.open('处理中...');
                $.post('/index/trade/orderPayConfirm',{id : '{$orderInfo["id"]}' ,type : 2},function (res) {
                    YDUI.dialog.loading.close();
                    dialog.toast(res.msg,'none',1000,function () {
                        location.reload();
                    });
                });
            });
        });
    }(jQuery);
</script>
<script src="/static/js/clipboard.min.js" type="text/javascript"></script>
<script type="text/javascript">
    //  复制银行卡
    var bank_no = new Clipboard('.bank_no', {
        text: function() {return "{$buy_user['bank_no']}";}
    });
    bank_no.on('success', function(e) {dialog.toast('复制成功','success',1000);});
    bank_no.on('error',function(e) {console.log(e);});
    // 复制手机号
    var phone = new Clipboard('.phone', {
        text: function() {return "{$buy_user['phone']}";}
    });
    phone.on('success', function(e) {dialog.toast('复制成功','success',1000);});
    phone.on('error',function(e) {console.log(e);});
    // 复制支付宝
    var alipay = new Clipboard('.alipay', {
        text: function() {return "{$buy_user['alipay']}";}
    });
    alipay.on('success', function(e) {dialog.toast('复制成功','success',1000);});
    alipay.on('error',function(e) {console.log(e);});
    // 复制姓名
    var Name = new Clipboard('.name', {
        text: function() {return "{$buy_user['name']}";}
    });
    Name.on('success', function(e) {dialog.toast('复制成功','success',1000);});
    Name.on('error',function(e) {console.log(e);});
</script>
<script>
    var $getCode = $('#J_GetCode');
    /* 定义参数 */
    $getCode.sendCode({
        disClass: 'btn-disabled',
        secs: {$orderInfo['expire_time']-time()},
        run: true,
        runStr: '<span class="badge badge-radius badge-warning">{%s}</span>秒',
        resetStr: '该订单已失效',
    });
</script>
</body>
</html>